package C;

import java.util.HashSet;
import java.util.Scanner;

public class C2My {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l1 = sc.nextInt();
        int l2 = sc.nextInt();
        int[] A = new int[l1];
        int sumA = 0;
        for(int i = 0;i<l1;i++){
            A[i]=sc.nextInt();
            sumA+=A[i];
        }
        int sumB = 0;
        int[] B = new int[l2];
        for (int i=0;i<l2;i++){
            B[i]=sc.nextInt();
            sumB+=B[i];
        }
        int half_diff = (sumA-sumB)/2;

        int minA = Integer.MAX_VALUE;
        String ans = "";

        for(int i=0;i<A.length;i++){
            int b = A[i]-half_diff;
            for(int j=0;j<B.length;j++){
                if(B[j]==b){
                    if(A[i]<minA){
                        minA=A[i];
                        ans = minA+" "+b;
                    }
                }
            }
        }
        System.out.println(ans);
    }



}
